package com.wangxiang.shop.product.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.wangxiang.shop.product.dao.SpuDao;
import com.wangxiang.shop.product.entity.SpuEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wangxiang.shop.product.entity.ShopTypeEntity;
import com.wangxiang.shop.product.service.ShopTypeService;
import com.wangxiang.common.utils.PageUtils;
import com.wangxiang.common.utils.R;




/**
 * 
 *
 * @author wangxiang
 * @email 2293672863@qq.com
 * @date 2022-04-07 21:18:21
 */
@RestController
@RequestMapping("product/shoptype")
public class ShopTypeController {
    @Autowired
    private ShopTypeService shopTypeService;
    @Autowired
    private SpuDao spuDao;

    /**
     * 第五次重构商品模块，定板，三级商品分类
     * @return
     */
    @RequestMapping("list")
    public R list(){
        List<ShopTypeEntity> shopTypeEntities = shopTypeService.shopList();
        return R.ok().put("list",shopTypeEntities);
    }

    /**
     * uni端请求商品的二级分类，分类页面
     * @return
     */
    @RequestMapping("typelist")
    public R twoType(){
        List<ShopTypeEntity> shopTypeEntities = shopTypeService.twoType();
        return R.ok().put("list",shopTypeEntities);
    }
    @RequestMapping("baritem")
    public R treeType(@RequestBody Integer parentId){

        List<ShopTypeEntity> shopTypeEntities = shopTypeService.threeType(parentId);
        return R.ok().put("list",shopTypeEntities);
    }
    @RequestMapping("threebar")
    public R threebar(){
        List<ShopTypeEntity> threebar = shopTypeService.threebar();
        return R.ok().put("list",threebar);
    }
    @RequestMapping("three")
    public R allList(){
        List<HashMap<String, Object>> list = shopTypeService.threeList();
        return R.ok().put("list",list);
    }
    @RequestMapping("mysql")
    public List<SpuEntity> mysql(){
        List<SpuEntity> list = spuDao.selectList(null);
        return list;
    }


}
